<div class="popup_body clearfix">
    <div class="tab_item" style="display:block;">
        <div class="ui_table">
            <form>
                <table cellpadding="0" cellspacing="0" width="100%">
                    <input type="hidden" name="id" value="${cabinetId}"/>
                    <tr>
                        <td align="right">日志时间：</td>
                        <td>
                            <input style="height: 30px" class="easyui-datebox" required editable="false"
                                   id="datetime_${pid}"
                                   name="date"/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">日志类型：</td>
                        <td>
                            <select name="type" class="easyui-combobox"
                                    required editable="false"
                                    style="height: 30px;">
                            <#list logType as e>
                                <option value="${e.value}">${e.getName()}</option>
                            </#list>
                            </select>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>

<script>
    (function () {
        var win = $('#${pid}'), jform = win.find('form');
        var form = jform[0];
        win.find('button.ok').click(function () {
            jform.form('submit', {
                url: '${contextPath}/security/hdw/cabinet/uploadLog.htm',
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close')

                        window.downloadFile('${controller.appConfig.staticUrl}'+json.message)
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });
        });
        win.find('button.close').click(function () {
            win.window('close');
        });
    })();
    window.downloadFile = function (sUrl) {

        //iOS devices do not support downloading. We have to inform user about this.
        if (/(iP)/g.test(navigator.userAgent)) {
            alert('Your device does not support files downloading. Please try again in desktop browser.');
            return false;
        }

        //If in Chrome or Safari - download via virtual link click
        if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
            //Creating new link node.
            var link = document.createElement('a');
            link.href = sUrl;

            if (link.download !== undefined) {
                //Set HTML5 download attribute. This will prevent file from opening if supported.
                var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
                link.download = fileName;
            }

            //Dispatching click event.
            if (document.createEvent) {
                var e = document.createEvent('MouseEvents');
                e.initEvent('click', true, true);
                link.dispatchEvent(e);
                return true;
            }
        }

        // Force file download (whether supported by server).
        if (sUrl.indexOf('?') === -1) {
            sUrl += '?download';
        }

        window.open(sUrl, '_self');
        return true;
    }

    window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
</script>


